home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE10 / GETCALST / LINE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  26KB  |  785 lines

  1.  
  2. #include <windows.h> 
  3. #include <windowsx.h> 
  4. #include "line.h" 
  5. #include "tapi.h"
  6.  
  7. #define BUFSIZE 256
  8. #define APIHIVERSION     0x00010028    /* 1.40 */
  9. #define APILOWVERSION    0x00010000    /* 1.0 */
  10. #define EXTHIVERSION     0x00010005    /* 1.5 */
  11. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  12. #define OWNER        0
  13. #define MONITOR      1
  14. #define MAX_CALL        3
  15. #define MAX_LINE        2
  16.  
  17.  
  18. #if defined (WIN32)
  19.     #define IS_WIN32 TRUE
  20. #else
  21.     #define IS_WIN32 FALSE
  22. #endif
  23.  
  24. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  25. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  26. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  27.  
  28. LPCTSTR lpszAppName = "lineGetCallStatus";
  29. LPCTSTR lpszTitle   = "lineGetCallStatus"; 
  30.  
  31. HINSTANCE hInst;   // current instance
  32. HWND hWnd;         // parent window handle
  33. HWND hListWnd;     // listbox
  34. HDC  hdc;
  35. TEXTMETRIC  tm ;
  36.  
  37. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  38.  
  39.  
  40. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  41.                       LPTSTR lpCmdLine, int nCmdShow)
  42. {
  43.    MSG      msg;
  44.    WNDCLASS wc;
  45.  
  46.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  47.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  48.    wc.cbClsExtra    = 0;                      
  49.    wc.cbWndExtra    = 0;                      
  50.    wc.hInstance     = hInstance;              
  51.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  52.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  53.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  54.    wc.lpszMenuName  = lpszAppName;              
  55.    wc.lpszClassName = lpszAppName;              
  56.  
  57.    if ( IS_WIN95 )
  58.    {
  59.       if ( !RegisterWin95( &wc ) )
  60.          return( FALSE );
  61.    }
  62.    else if ( !RegisterClass( &wc ) )
  63.       return( FALSE );
  64.  
  65.    hInst = hInstance; 
  66.  
  67.    hWnd = CreateWindow( lpszAppName, 
  68.                         lpszTitle,    
  69.                         WS_OVERLAPPEDWINDOW, 
  70.                         CW_USEDEFAULT, 0, 
  71.                         CW_USEDEFAULT, 0,  
  72.                         NULL,              
  73.                         NULL,              
  74.                         hInstance,         
  75.                         NULL               
  76.                       );
  77.  
  78.    if ( !hWnd ) 
  79.       return( FALSE );
  80.  
  81.    ShowWindow( hWnd, nCmdShow ); 
  82.    UpdateWindow( hWnd );         
  83.  
  84.    while( GetMessage( &msg, NULL, 0, 0) )   
  85.    {
  86.       TranslateMessage( &msg ); 
  87.       DispatchMessage( &msg );  
  88.    }
  89.  
  90.    return( msg.wParam ); 
  91. }
  92.  
  93.  
  94. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  95. {
  96.     WNDCLASSEX wcex;
  97.  
  98.    wcex.style         = lpwc->style;
  99.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  100.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  101.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  102.    wcex.hInstance     = lpwc->hInstance;
  103.    wcex.hIcon         = lpwc->hIcon;
  104.    wcex.hCursor       = lpwc->hCursor;
  105.    wcex.hbrBackground = lpwc->hbrBackground;
  106.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  107.    wcex.lpszClassName = lpwc->lpszClassName;
  108.  
  109.    // Added elements for Windows 95.
  110.    //...............................
  111.    wcex.cbSize = sizeof(WNDCLASSEX);
  112.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  113.                             IMAGE_ICON, 16, 16,
  114.                             LR_DEFAULTCOLOR );
  115.             
  116.    return RegisterClassEx( &wcex );
  117. }
  118.  
  119. #define CONFCALL    1
  120. #define CONSULT      2
  121.  
  122. enum CallState
  123. {
  124.     Idle,
  125.     Offering,
  126.     Accepted,
  127.     Dialtone,
  128.     Dialing,
  129.     Ringback,
  130.     Busy,
  131.     Special,
  132.     Connected,
  133.     Proceeding,
  134.     Conferenced,
  135.     Onholdconf,
  136.     Disconnected,
  137.     Unknown
  138. };
  139.  
  140. typedef struct tagMYINFO      // general application information
  141. {
  142.     HLINEAPP lineApp;         // instance handle TAPI gives back to us                                                                              through lineInitialize()
  143.     DWORD dwNumDevices;       // number of available devices
  144.     DWORD dwAPIVersion;       // API version the line supports
  145.      DWORD dwExtVersion;           // extended version
  146.     char szLocation[128];     // location        
  147.      char szCallingCard[128];  // calling card being used
  148.     char szAreaCode[4];       // area code       
  149.     char szCountry[128];      // calling card being used
  150. } MYINFO;
  151.  
  152. typedef struct tagLINEINFO  // information on an open line
  153. {
  154.     DWORD dwNumAddress;     // number of available addresses on the line 
  155.     HLINE hLine;            // handle to the line as returned by lineOpen 
  156.      DWORD dwLineID;         // the line ID of this line
  157.     char  szLineName[128];  // the line's name 
  158.  
  159. } MYLINEINFO;
  160.  
  161. typedef struct tagMYCALLINFO  //information on a call                     
  162. {
  163.     
  164. DWORD       eCallState;    // TAPI's line call State, set as user-defined enums
  165. DWORD      dwRequestID;   // requestID returned by async TAPI functions lineMakeCall/lineDropCall
  166. DWORD      dwAddressID;   // the originating address ID of the call being made 
  167. LPCSTR     lpszAddress;    
  168. HLINE     hLine;         // handle to the line 
  169. HCALL        hCall;         // handle to the call 
  170.    
  171. char szDialString[TAPIMAXDESTADDRESSSIZE];  //phone number being dialed
  172. char szDialStringOriginal[TAPIMAXDESTADDRESSSIZE];
  173. char szDialStringCanonical[TAPIMAXDESTADDRESSSIZE];
  174. char szCalledParty[TAPIMAXCALLEDPARTYSIZE]; // name of the party
  175. DWORD dwTranslateResults;
  176.         
  177. } MYCALLINFO;
  178.  
  179. enum CallAction     // Declare enum type CallAction (used in lineSetAppSpecific)
  180. {
  181.    HOLD,            // hold the call
  182.    TRANSFER,        // transfer the call
  183.    REDIRECT,        // redirect the call
  184.    DROP,            // drop the call
  185.    PARK             // park the call
  186. }; 
  187.  
  188. MYINFO myInfo;          //instance of MYINFO structure
  189. MYLINEINFO myLineInfo[MAX_LINE];  //instance of MYLINEINFO structure
  190. MYCALLINFO myCallInfo[MAX_CALL]; //array of MYCALLINFO strcuture
  191.  
  192. LONG lRet;        //return code
  193. char buf[BUFSIZE];    // buffer for debug message
  194.  
  195. DWORD dwLineID = 0;
  196. DWORD i;
  197. LINEEXTENSIONID        ext_id;
  198. LINEDEVCAPS            *plineDevCaps;
  199. LINEADDRESSCAPS        *plineAddressCaps;
  200. LINEADDRESSSTATUS     *plineAddressStat;
  201. LINECALLINFO            *plineCallInfo;
  202. LINECALLSTATUS         *plineCallStatus;
  203. LINECALLLIST            *plineCallList;
  204. LINEDEVSTATUS           *plineDevStatus;
  205. LINETRANSLATECAPS       *plineTranslateCaps;
  206. LINETRANSLATEOUTPUT  *plineTranslateOutput;
  207. LINECALLPARAMS           *plineCallParams;
  208. LINEDEVSTATUS           *plineDevStatus;
  209. LINEFORWARDLIST        *plineForwardList;
  210. LINETRANSLATECAPS       *plineTranslateCaps;
  211. LINEREQMAKECALL       lineReqMakeCall;
  212. VARSTRING               *pDeviceConfig;
  213. VARSTRING               *pDeviceId;
  214. VARSTRING               *pNonDirAddress;
  215.  
  216. LPLINELOCATIONENTRY  lineLocEntry;
  217. LPLINECARDENTRY        lineCardEntry;
  218. LINECOUNTRYLIST         *plineCountryList;
  219. LPLINECOUNTRYENTRY   lineCE;
  220.  
  221. LPSTR                lpData;
  222.  
  223. HICON                hIcon = NULL;        //used in lineGetID();
  224. DWORD                dwNumRings;    //used in lineGetNumRings();
  225. HCALL                hConsultCall; //handle to consultation linePrepareAddToConference, SetupConference
  226. HCALL                hConfCall; //handle to consultation linePrepareAddToConference, SetupConference   
  227. HCALL                hParkedCall;
  228.  
  229. DWORD                dwCompletionID;  //used in lineCompleteCall()
  230.  
  231. char                szName[128];
  232. char                szNumber[128];
  233. char                szDigits[128];
  234. char                szDevConfig[128];
  235.  
  236. LONG lRet;
  237. char buf[BUFSIZE];
  238.  
  239. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  240. {
  241.    switch( uMsg )
  242.    {
  243.       case WM_COMMAND :
  244.          switch( LOWORD( wParam ) )
  245.          {
  246.             case IDM_RUN :
  247.                DialogBox( hInst, "IDD_DIALNUM", hWnd, (DLGPROC)Dial );
  248.                break;
  249.  
  250.             case IDM_GETCALLSTATUS :
  251.                //query only if we have a connected call
  252.                //................................................      
  253.                if (myCallInfo[0].eCallState != Connected)
  254.                {
  255.                   MessageBox (hWnd, "Place your call in the connected state and try again...", "", MB_OK);
  256.                   break;
  257.                }
  258.  
  259.                 //allocate buffer for the LINECALLSTATUS structure 
  260.                //...................................................
  261.                plineCallStatus = (LINECALLSTATUS*) calloc (1,  
  262.                                    sizeof(LINECALLSTATUS) + 1000);
  263.                plineCallStatus->dwTotalSize = sizeof(LINECALLSTATUS)+1000;
  264.                
  265.                // get call status
  266.                //..................................
  267.                lRet = lineGetCallStatus(myCallInfo[0].hCall,plineCallStatus);
  268.                
  269.                if (lRet == 0)
  270.                {
  271.                   wsprintf (buf, "lineGetCallStatus succeeded!");
  272.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  273.                                       
  274.                   //check to see if we have owner privilege.....
  275.                   if (plineCallStatus->dwCallPrivilege & 
  276.                                       LINECALLPRIVILEGE_OWNER)            
  277.                         {
  278.                       wsprintf (buf, "Application has owner privilege!");
  279.                            SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  280.                             wsprintf (buf, "The current call state is : %xlx", plineCallStatus->dwCallState);
  281.                            SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  282.                         }
  283.                }
  284.                else 
  285.                {
  286.                   wsprintf ( buf,"lineGetCallStatus failed, err=x%lx",lRet);
  287.                   lineError(lRet);
  288.                }
  289.               free (plineCallStatus);
  290.               break;
  291.          
  292.             case IDM_ABOUT :
  293.             {
  294.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  295.                break;
  296.             }
  297.  
  298.             case IDM_EXIT :
  299.             {
  300.                for (i = 0; i < myInfo.dwNumDevices; i++)
  301.                        lineClose(myLineInfo[i].hLine);
  302.                     lineShutdown(myInfo.lineApp);
  303.                DestroyWindow( hWnd );
  304.                break;
  305.             }
  306.             }                  
  307.                  
  308.          break;
  309.  
  310.       case WM_CREATE :
  311.       {
  312.          hdc = GetDC (hWnd) ;
  313.          GetTextMetrics (hdc, &tm) ;
  314.          ReleaseDC (hWnd, hdc) ;
  315.  
  316.          hListWnd = CreateWindowEx( 0, "listbox", 
  317.                         " ",    
  318.                         WS_CHILD | WS_VISIBLE,  
  319.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  320.                         tm.tmAveCharWidth * 16 +
  321.                                    GetSystemMetrics (SM_CXVSCROLL), 
  322.                         tm.tmHeight * 5,  
  323.                         hWnd,              
  324.                         NULL,              
  325.                         hInst,         
  326.                         NULL               
  327.                         );
  328.  
  329.          
  330.          //lineInitialize
  331.             //...............................................
  332.          lRet = lineInitialize(&myInfo.lineApp, hInst, lineCallback, NULL, &myInfo.dwNumDevices);
  333.          if (lRet == 0) 
  334.          {
  335.             wsprintf (buf, "lineInitialize suceeded!");
  336.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  337.            }
  338.          else 
  339.           {
  340.                wsprintf ( buf,"lineInitialize failed, err=x%lx",lRet);
  341.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  342.                lineError(lRet);
  343.                break;
  344.          }                    
  345.          
  346.          //lineNegotiateAPIVersion
  347.           //...............................................
  348.          lRet = lineNegotiateAPIVersion(myInfo.lineApp, 0, APILOWVERSION, APIHIVERSION, 
  349.                                            &myInfo.dwAPIVersion, &ext_id);
  350.          if (lRet == 0)                        
  351.          {
  352.             wsprintf (buf, "lineNegotiateAPIVersion suceeded!");
  353.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  354.          }
  355.          else 
  356.           {
  357.                wsprintf (buf, "lineNegotiateAPIVersion failed, err=x%lx",
  358.                            lRet);
  359.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  360.                lineError(lRet);
  361.                lineShutdown (myInfo.lineApp);
  362.             break;
  363.          }
  364.  
  365.           //lineNegotiateExtVersion
  366.           //...............................................
  367.          lRet = lineNegotiateExtVersion(myInfo.lineApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  368.                                            EXTHIVERSION, &myInfo.dwExtVersion);
  369.          if (lRet == 0)                        
  370.          {
  371.             wsprintf (buf, "lineNegotiateExtVersion suceeded!");
  372.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  373.  
  374.          }
  375.           else 
  376.           {
  377.                wsprintf (buf, "lineNegotiateExtVersion failed, err=x%lx",
  378.                      lRet);
  379.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  380.               lineError(lRet);
  381.       
  382.          }
  383.  
  384.           //lineGetDevCaps
  385.           //for each line device, get capabilities until we find one that supports
  386.          //interactive voice 
  387.           //...............................................
  388.          plineDevCaps = (LINEDEVCAPS *) calloc (1, sizeof(LINEDEVCAPS)+1000);
  389.          plineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS) + 1000;
  390.          for (i = 0; i < myInfo.dwNumDevices; i++)
  391.          {
  392.             lineGetDevCaps(myInfo.lineApp, i, myInfo.dwAPIVersion, 0, plineDevCaps);
  393.             if (plineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE) 
  394.             {
  395.                
  396.                myLineInfo[i].dwNumAddress = plineDevCaps->dwNumAddresses;
  397.                   myLineInfo[i].dwLineID = i;
  398.                    if (plineDevCaps->dwLineNameSize > 0)
  399.                           strcpy(myLineInfo[i].szLineName,((LPSTR)(plineDevCaps)+plineDevCaps->dwLineNameOffset));
  400.              }
  401.           }
  402.  
  403.          //lineOpen
  404.           //................................................................
  405.           lRet = lineOpen(myInfo.lineApp,myLineInfo[OWNER].dwLineID,&myLineInfo[OWNER].hLine,
  406.                            myInfo.dwAPIVersion,0,(DWORD)lineCallback, LINECALLPRIVILEGE_NONE,
  407.                             LINEMEDIAMODE_DATAMODEM, NULL);
  408.           if (lRet == 0)
  409.           {
  410.             wsprintf (buf, "lineOpen suceeded!");
  411.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;         }
  412.            else 
  413.            {
  414.                wsprintf ( buf,"lineOpen failed, err=x%lx", lRet);
  415.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  416.                lineError(lRet);
  417.           }
  418.        
  419.          break;
  420.       }
  421.       
  422.       case WM_SIZE:
  423.           MoveWindow(hListWnd,0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  424.          break;
  425.  
  426.       case WM_DESTROY :
  427.               PostQuitMessage(0);
  428.               break;
  429.  
  430.       default :
  431.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  432.    }
  433.  
  434.    return( 0L );
  435. }
  436.  
  437.  
  438.  
  439. /****************************************************************************
  440.     FUNCTION: lineCallback
  441.     PURPOSE:  callback function handles line events
  442. ****************************************************************************/
  443. LRESULT CALLBACK lineCallback (DWORD dwDevice, DWORD dwMsg,
  444.                                        DWORD dwCallbackInst, DWORD dwParam1,
  445.                                        DWORD dwParam2,DWORD dwParam3)
  446. {
  447.    switch (dwMsg)
  448.    {
  449.       case LINE_CALLSTATE:
  450.        {
  451.             for (i = 0; i < MAX_CALL; i++)
  452.            {
  453.                 if (dwDevice = (DWORD) myCallInfo[i].hCall) 
  454.                  switch (dwParam1)
  455.                  {
  456.                     case LINECALLSTATE_IDLE:
  457.                         myCallInfo[i].eCallState = Idle;
  458.                   break;
  459.                     
  460.                     case LINECALLSTATE_OFFERING:
  461.                   myCallInfo[i].eCallState = Offering;
  462.                   break;
  463.                                    
  464.                     case LINECALLSTATE_ACCEPTED:
  465.                         myCallInfo[i].eCallState = Accepted;
  466.                         break;
  467.                     
  468.                     case LINECALLSTATE_DIALTONE:
  469.                         myCallInfo[i].eCallState = Dialtone;
  470.                   break;
  471.                     
  472.                     case LINECALLSTATE_DIALING:
  473.                         myCallInfo[i].eCallState = Dialing;
  474.                         break;
  475.                   
  476.                   case LINECALLSTATE_RINGBACK:
  477.                         myCallInfo[i].eCallState = Ringback;
  478.                         break;
  479.             
  480.                     case LINECALLSTATE_BUSY:
  481.                         myCallInfo[i].eCallState = Busy;
  482.                         break;
  483.             
  484.                     case LINECALLSTATE_SPECIALINFO:
  485.                         myCallInfo[i].eCallState = Special;
  486.                        break;
  487.             
  488.                     case LINECALLSTATE_CONNECTED:
  489.                        myCallInfo[i].eCallState = Connected;
  490.                   break;
  491.  
  492.                     case LINECALLSTATE_PROCEEDING:
  493.                         myCallInfo[i].eCallState = Proceeding;
  494.                        break;
  495.             
  496.                     case LINECALLSTATE_CONFERENCED:
  497.                         myCallInfo[i].eCallState = Conferenced;
  498.                        break;
  499.             
  500.                     case LINECALLSTATE_ONHOLDPENDCONF:
  501.                         break;
  502.                 
  503.                case LINECALLSTATE_DISCONNECTED:
  504.                         myCallInfo[i].eCallState = Disconnected;
  505.                        break;
  506.             
  507.                     case LINECALLSTATE_UNKNOWN:
  508.                         myCallInfo[i].eCallState = Unknown;
  509.                        break;
  510.        
  511.              }
  512.           }
  513.        }
  514.  
  515.        case LINE_MONITORMEDIA:
  516.            break;
  517.  
  518.        case LINE_MONITORDIGITS:
  519.           break;
  520.  
  521.          case LINE_MONITORTONE:
  522.           break;
  523.    
  524.        //error handling for functions completed asynchronously
  525.         //.....................................................
  526.        case LINE_REPLY:
  527.         {
  528.             for (i = 0; i < MAX_CALL; i++)
  529.            {
  530.                 if (dwParam1 = myCallInfo[i].dwRequestID)
  531.                {
  532.                    if (dwParam2 != 0)
  533.                    {
  534.                        lineError((LONG) dwParam2);
  535.                        break;
  536.                    }
  537.                }
  538.            }
  539.         break;
  540.         }
  541.  
  542.         case LINE_GENERATE:
  543.           break;
  544.      
  545.        case LINE_REQUEST:
  546.          break;
  547.  
  548.         case LINE_GATHERDIGITS:
  549.            break;
  550.    }
  551.  
  552.    return (TRUE);
  553.  
  554.  
  555. /****************************************************************************
  556.     FUNCTION: lineError
  557.     PURPOSE:  line error messages
  558. ****************************************************************************/
  559. void lineError (LONG lrc)
  560. {
  561.  switch (lrc) {
  562.     case LINEERR_INVALAPPHANDLE:
  563.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  564.        break;
  565.     case LINEERR_BADDEVICEID:
  566.        MessageBox (hWnd,"The specified line device ID is out of range.", "", 
  567.                    MB_OK);
  568.        break;
  569.     case LINEERR_INCOMPATIBLEAPIVERSION:
  570.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  571.        break;
  572.     
  573.     case LINEERR_ADDRESSBLOCKED:
  574.        MessageBox (hWnd, "Address was blocked.", "", MB_OK);
  575.        break;
  576.  
  577.     case LINEERR_BEARERMODEUNAVAIL:
  578.        MessageBox (hWnd, "Bearer Mode Unavailable.", "", MB_OK);
  579.        break;
  580.  
  581.     case LINEERR_CALLUNAVAIL:
  582.        MessageBox (hWnd, "Call appearances in use..", "", MB_OK);
  583.        break;
  584.  
  585.     case LINEERR_INUSE:
  586.        MessageBox (hWnd, "Line in Use.", "", MB_OK);
  587.        break;
  588.     
  589.     case LINEERR_INVALADDRESS:
  590.        MessageBox (hWnd, "Invalid Address.", "", MB_OK);
  591.        break;
  592.  
  593.     case LINEERR_INVALADDRESSID:
  594.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  595.        break;
  596.  
  597.     case LINEERR_INVALCALLPARAMS:
  598.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  599.        break;
  600.      
  601.     case LINEERR_INCOMPATIBLEEXTVERSION:
  602.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  603.        break;
  604.     case LINEERR_NOMEM:
  605.        MessageBox (hWnd, "No memory","", MB_OK);
  606.        break;
  607.     case LINEERR_NODRIVER:
  608.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  609.        break;
  610.     case LINEERR_RESOURCEUNAVAIL:
  611.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  612.        break;
  613.     case LINEERR_INVALPRIVSELECT:
  614.        MessageBox (hWnd, "Requested invalid priviledges", "", MB_OK);
  615.        break;
  616.     case LINEERR_INVALMEDIAMODE:
  617.        MessageBox (hWnd, "Requested invalid media mode", "", MB_OK);
  618.        break;
  619.     case LINEERR_LINEMAPPERFAILED:
  620.        MessageBox (hWnd, "Line mapper failed", "", MB_OK);
  621.        break;
  622.     case LINEERR_INVALPOINTER:
  623.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  624.                    "", MB_OK);
  625.        break;
  626.     case LINEERR_OPERATIONFAILED:
  627.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  628.        break;
  629.     case LINEERR_INVALLINEHANDLE:
  630.        MessageBox (hWnd, "Invalid line handle", "", MB_OK);
  631.        break;
  632.     case LINEERR_INVALCALLHANDLE:
  633.        MessageBox (hWnd, "Invalid call handle", "", MB_OK);
  634.        break;
  635.     case LINEERR_INVALCALLSELECT:
  636.        MessageBox (hWnd, "Invalid call selection", "", MB_OK);
  637.        break;
  638.     case LINEERR_NODEVICE:
  639.        MessageBox (hWnd, "No associated device for given class",
  640.                    "", MB_OK);
  641.        break;
  642.     case LINEERR_OPERATIONUNAVAIL:
  643.        MessageBox (hWnd, "The operation is unavailable",
  644.                    "", MB_OK);
  645.        break;
  646.     case LINEERR_INVALPARAM:
  647.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  648.        break; 
  649.  
  650.     case LINEERR_TARGETNOTFOUND:
  651.         MessageBox(hWnd, "Target Not Found", "", MB_OK);
  652.        break; 
  653.  
  654.    case LINEERR_NOREQUEST:
  655.       MessageBox(hWnd, "No outstanding Assisted Telephony requests.", "", MB_OK);
  656.        break; 
  657.    }
  658. }
  659.  
  660. LRESULT CALLBACK Dial ( HWND hDlg,           // window handle of the dialog box
  661.                         UINT message,        // type of message
  662.                         WPARAM wParam,       // message-specific information
  663.                         LPARAM lParam)
  664. {
  665.    switch (message) 
  666.    {
  667.        case WM_INITDIALOG:  // message: initialize dialog box
  668.                return (TRUE);
  669.  
  670.        case WM_COMMAND:                              // message: received a command
  671.          if (   LOWORD(wParam) == IDOK )        // "OK" box selected?
  672.          {
  673.             GetDlgItemText(hDlg, IDC_NAME, szName, 128);
  674.                 GetDlgItemText(hDlg, IDC_NUMBER, szNumber, 128);
  675.                                       
  676.  
  677.                 // put up a dialog box to obtain a string to dial from the user
  678.                //...........................................................
  679.                strcpy(myCallInfo[0].szDialStringOriginal, szNumber); 
  680.                
  681.                //allocate buffer for the LINEADDRESSCAPS strucuture 
  682.                //...................................................
  683.                plineTranslateOutput = (LINETRANSLATEOUTPUT *) calloc (1, sizeof(LINETRANSLATEOUTPUT)+1000);
  684.             plineTranslateOutput->dwTotalSize = sizeof(LINETRANSLATEOUTPUT) + 1000;
  685.               
  686.                // translate the Address to a dialable address and Canonical address
  687.                //.....................................................................
  688.                lRet = lineTranslateAddress(myInfo.lineApp, myLineInfo[OWNER].dwLineID, myInfo.dwAPIVersion,
  689.                                            myCallInfo[0].szDialStringOriginal, 0, 0, plineTranslateOutput);
  690.                               
  691.                if (lRet == 0)
  692.                {
  693.                        
  694.                    strncpy(myCallInfo[0].szDialString, (LPSTR)(plineTranslateOutput)
  695.                             + plineTranslateOutput->dwDialableStringOffset,
  696.                              plineTranslateOutput->dwDialableStringSize); 
  697.     
  698.                     strncpy(myCallInfo[0].szDialStringCanonical,(LPSTR)(plineTranslateOutput) 
  699.                             + plineTranslateOutput->dwDisplayableStringOffset,
  700.                             plineTranslateOutput->dwDisplayableStringSize); 
  701.                                            
  702.                    myCallInfo[0].dwTranslateResults = plineTranslateOutput->dwTranslateResults;
  703.                 }
  704.  
  705.                else 
  706.                {
  707.                     wsprintf ( buf,"lineTranslateAddress failed, err=x%lx", lRet);
  708.                     lineError(lRet);
  709.                    break;
  710.             }
  711.            
  712.                //lineMakeCall
  713.                //................................................................
  714.                           
  715.                plineCallParams = (LINECALLPARAMS *) calloc (1, sizeof(LINECALLPARAMS)+1000);
  716.             plineCallParams->dwTotalSize = sizeof(LINECALLPARAMS) + 1000;
  717.  
  718.                plineCallParams->dwBearerMode = LINEBEARERMODE_VOICE;
  719.                plineCallParams->dwMediaMode =  LINEMEDIAMODE_DATAMODEM;
  720.                plineCallParams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
  721.                plineCallParams->dwAddressMode    = LINEADDRESSMODE_ADDRESSID;
  722.                plineCallParams->dwAddressID    = 0;
  723.                plineCallParams->dwMinRate    = 1200;
  724.                plineCallParams->dwMaxRate    = 2400;
  725.                             
  726.                lRet = lineMakeCall(myLineInfo[OWNER].hLine,&myCallInfo[0].hCall, 
  727.                                       myCallInfo[0].szDialString ,0,  plineCallParams);
  728.            
  729.             if (lRet > 0)
  730.                {
  731.                wsprintf (buf, "lineMakeCall suceeded!");
  732.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  733.                    myCallInfo[0].dwRequestID = lRet;
  734.                 }
  735.             else 
  736.                {
  737.                    wsprintf ( buf,"lineMakeCall failed, err=x%lx", lRet);
  738.                     lineError(lRet);
  739.                    break;
  740.             }
  741.             
  742.             EndDialog(hDlg, TRUE);        // Exit the dialog
  743.             return (TRUE);
  744.          }
  745.  
  746.             if (   LOWORD(wParam) == IDCANCEL)         // "OK" box selected?
  747.          {
  748.             EndDialog(hDlg, TRUE);        // Exit the dialog
  749.             return (TRUE);
  750.          }
  751.          break;
  752.  
  753.  
  754.    }
  755.  
  756.    return (FALSE); 
  757. }
  758.  
  759.  
  760. LRESULT CALLBACK About( HWND hDlg,           
  761.                         UINT message,        
  762.                         WPARAM wParam,       
  763.                         LPARAM lParam)
  764. {
  765.    switch (message) 
  766.    {
  767.        case WM_INITDIALOG: 
  768.                return (TRUE);
  769.  
  770.        case WM_COMMAND:                              
  771.                if (   LOWORD(wParam) == IDOK         
  772.                    || LOWORD(wParam) == IDCANCEL)    
  773.                {
  774.                        EndDialog(hDlg, TRUE);        
  775.                        return (TRUE);
  776.                }
  777.                break;
  778.    }
  779.  
  780.    return (FALSE); 
  781. }
  782.  
  783.  
  784.